<template>
	<view class="bg-white flex align-center justify-center" style="height: 100%;width: 100%;padding-top: 200rpx;">
		<view>
			<view class="text-center">
				<image src="/static/logo.png" class="solids p-1" style="width: 200rpx;height: 200rpx;"></image>
				<view class="text-bold text-lg">基础项目</view>
			</view>
			<view class="margin-top p-3" style="">
				<button class="cu-btn bg-cyan" style="width: 100%;" @click="loginClick">微信一键登录</button>
			</view>
			<view class="flex align-center mt-3 text-s1 justify-center">
				<view class="round text-s4 flex align-center justify-center" style="height: 30rpx;width: 30rpx;"
					:class="curData.isTongyi?'cuIcon-check bg-cyan':'bg-grey'"
					@click="curData.isTongyi = !curData.isTongyi">
				</view>
				<view class="ml-1 text-c3">
					<text @click="curData.isTongyi = !curData.isTongyi">我已阅读并同意</text>
					<text class="text-blue" @click="xieyiClick">《用户协议》</text>
					和
					<text class="text-blue" @click="yinsiClick">《隐私协议》</text>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				curData: {
					isTongyi: true,
				},
			}
		},
		onLoad() {},
		methods: {
			loginClick(e) {
				console.info("点击", e)
				//是否同意协议
				if (this.curData.isTongyi === false) {
					uni.$common.modalWarin("请先同意用户协议")
					return
				}
				//小程序无感登录
				uni.login({
					success: res => {
						if (res.code) {
							uni.$api.userLogin({
								code: res.code,
							}).then((data) => {
								uni.setStorageSync('token', data.token)
								uni.setStorageSync('userInfo', data.userInfo)
								this.$common.toastSuc("登录成功", () => {
									uni.switchTab({
										url: "/pages/index/index"
									})
								})
							})
						}
					},
					fail: (e) => {
						console.info("登录失败", e)
						event(false);
					}
				})
			},
			xieyiClick() {
				uni.$common.navTo("/subpkg/commons/web-show/web-show", {
					type: "CONFIG",
					title: data.name,
					content: "USER_XIEYI"
				})
			},
			yinsiClick() {
				uni.$common.navTo("/subpkg/commons/web-show/web-show", {
					type: "CONFIG",
					title: data.name,
					content: "USER_YINSI"
				})
			}
		},
	}
</script>

<style scoped lang="scss">
</style>